/**
 * This class will display a screen summarizing the event or sessional date that 
 * was clicked from the list of items. It contains the date, title and a brief
 * description of the event or deadline.
 * @author Chirag Mistry
 */

package ca.uwo.android.mustangs;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import ca.uwo.android.BaseMenuActivity;
import ca.uwo.android.R;

public class MustangsDateItemSummary extends BaseMenuActivity {
	
	
	private static final String TAG_NAME = "MustangsDateItemSummary";//Application

	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.mustangs_datesfeed_iteminfoscreen); // set
																	// layout

		// access the date, title and summary fields from the layout file
		TextView locationField = (TextView) findViewById(R.id.location);
		TextView dateField = (TextView) findViewById(R.id.date);
		TextView titleField = (TextView) findViewById(R.id.title);
		TextView resultsField = (TextView) findViewById(R.id.results);

		// get the date, event and summary for the clicked item
		String date = getIntent().getExtras().getString("DATE");
		String title = getIntent().getExtras().getString("TITLE");
		String location = getIntent().getExtras().getString("LOCATION");
		String link = getIntent().getExtras().getString("LINK");
		String results = getIntent().getExtras().getString("RESULTS");

		link = "<a href=\"" + link + "\">More...</a>";

		// populate the fields with the information
		dateField.setText(date);
		titleField.setText(title);
		locationField.setText(location);
		resultsField.setText(results);

	}

	/**
	 * This method is called when a title is clicked. It opens a webpage to the
	 * url.
	 * 
	 * @param v
	 *            the button view that is clicked
	 */
	public void onMustangsScheduleTitleClick(View v) {

		String link = getIntent().getExtras().getString("LINK");
		
//		Log.i(TAG_NAME, "Link found for item = " + link);

		if (link != null) {

			// show url in browser
			Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
			startActivity(browser);
		}
	}
}
